<%-- 
    Document   : view
    Created on : Oct 23, 2011, 3:08:00 PM
    Author     : Yudi Retanto
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="/header.jsp"></jsp:include>
<h1>
    Flight
</h1>

<script type="text/javascript">
    $(function() {
        $( "#iDate" ).datepicker({ minDate: 0, maxDate: "+1M" });
    });
    function airportChange(){
        $('#defAirport').remove(); 
    }
    function getSchedule(){
        airport = $("#sAirport").val();
        date = $("#iDate").val();
        if(airport < 0){
            alert("Tolong pilih airport keberangkatan");
        } else if(date==""){
            alert("Tolong masukkan tanggal keberangkatan");
        } else {
            date = new Date(date);
            date = date.getTime();
            $('#flightSchedule').load('./flights?action=view&get=schedule&airport='+airport+'&date='+date);
        }
        return false;
    }
</script>
<form onsubmit="return getSchedule()">
<table class="filterForm">
    <tr>
        <td style="width: 20%;">
            <label for="airport">Bandara Keberangkatan :</label>
        </td>
        <td>
            <select id="sAirport" name="airport" onchange="airportChange()">
                <option id="defAirport" value="-1" selected="selected">Pilih Airport Keberangkatan</option>
                <c:forEach items="${airports}" var="airport">
                    <option value="${airport.getID()}">${airport.getCityName()} - ${airport.getName()}</option>
                </c:forEach>
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <label for="date">Tanggal Keberangkatan :</label>
        </td>
        <td>
            <input type="text" name="date" id="iDate" readonly/>
        </td>
    </tr>
    <tr>
        <td>
            <input type="submit" value="submit"/>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <table id="flightSchedule" class="viewSchedule">
                
            </table>
        </td>
    </tr>
</table>
</form>
<jsp:include page="/footer.jsp"></jsp:include>